package com.jsjosem.aftersales.api;

import com.jsjosem.aftersales.data.request.AcceptWorkOrderRequest;
import com.jsjosem.aftersales.data.request.AllotWorkRequest;
import com.jsjosem.aftersales.data.request.WorkOrderRequest;
import com.jsjosem.aftersales.data.request.WorkReceiptRequest;
import com.jsjosem.aftersales.data.response.BaseResponse;
import com.jsjosem.aftersales.data.response.PageResponse;
import com.jsjosem.aftersales.data.response.WorkOrderResponse;
import com.jsjosem.aftersales.data.response.WorkRankingsResponse;

import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface WorkOrderApi {

    /**
     * 获取工单列表
     */
    @GET("/wos")
    Call<PageResponse<WorkOrderResponse>> getByPage(@Query("date_type") String dateType,
                                                    @Query("date_start") String dateStart,
                                                    @Query("date_end") String dateEnd,
                                                    @Query("about_me") String aboutMe,
                                                    @Query("status") String status,
                                                    @Query("type") String type,
                                                    @Query("page") int page,
                                                    @Query("limit") int limit);

    /**
     * 创建工单
     */
    @POST("/wos")
    Call<BaseResponse<Void>> createOrder(@Body WorkOrderRequest request);

    /**
     * 创建工单
     */
    @POST("/wos/{id}/allot")
    Call<BaseResponse<Void>> allotOrder(@Path("id") String id, @Body AllotWorkRequest request);

    /**
     * 获取工单详情
     *
     * @param workOrderId
     * @return
     */
    @GET("/wos/{id}")
    Call<BaseResponse<WorkOrderResponse>> getById(@Path("id") String workOrderId);

    /**
     * 接单
     *
     * @param workOrderId
     * @return
     */
    @POST("/wos/{id}/accept")
    Call<BaseResponse<Void>> accept(@Path("id") String workOrderId, @Body AcceptWorkOrderRequest request);

    /**
     * 处理工单
     *
     * @param workOrderId
     * @return
     */
    @POST("/wos/{id}/start")
    Call<BaseResponse<Void>> start(@Path("id") String workOrderId);

    /**
     * 完成工单并回执
     *
     * @param workOrderId
     * @return
     */
    @POST("/wos/{id}/receipt")
    Call<BaseResponse<Void>> receipt(@Path("id") String workOrderId,
                                     @Body WorkReceiptRequest request);

    /**
     * 获取工单各状态数量
     *
     * @return
     */
    @GET("/wos/status_counts")
    Call<BaseResponse<Map<String, Integer>>> getStatusCounts();

    /**
     * 工单数量统计
     *
     * @return
     */
    @GET("/wo_count_statistic")
    Call<BaseResponse<Map<String, Integer>>> woCountStatistic();

    /**
     * 工单处理完成排行榜
     *
     * @return
     */
    @GET("/wo_rankings")
    Call<BaseResponse<List<WorkRankingsResponse>>> woRankings();

}
